package com.yidushishizijie;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

public class CompletableFutureDemo {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        Integer integer = CompletableFuture.supplyAsync(() ->{
            System.out.println(Thread.currentThread().getName()+"有返回，insert mysql ok");
            return 1024;
        }).whenComplete((t,u) ->{
            System.out.println("******t:"+t);
            System.out.println("******u:"+u);
        }).exceptionally(f ->{
            System.out.println("******expection:"+f.getMessage());
            return 404;
        }).get();
    }
}
